package com.twu.biblioteca;

import com.twu.biblioteca.model.bookModel;
import com.twu.biblioteca.model.movieModel;
import com.twu.biblioteca.model.user;
import com.twu.biblioteca.service.*;

import java.io.InputStream;
import java.util.Scanner;

public class BibliotecaApp {
    static int MAX=10;

    static setup setupBook=new setup();
    private static user[] userList;
    private static bookModel[] bookList;
    private static movieModel[] movieList;
    static setupMovieList setupMovieList=new setupMovieList();
    static setupUsers setupUsers=new setupUsers();
    static login login=new login();
    public static void main(String[] args) {

        InputStream in= System.in;
        bookList=new bookModel[MAX];
        movieList = new movieModel[MAX];
        userList =new user[MAX];
        menuOption Menu = new menuOption();
        System.out.println("welcome to Biblioteca!"+"\n Please login.");

        bookList=setupBook.setBookList(bookList);
        movieList=setupMovieList.setMovieList(movieList);
        userList=setupUsers.setUsers(userList);
        int len =login.checkLogin(userList,in);
        if(len<userList.length) {
          if (userList[len].getIdentity().equals("customer")) {
          setupBook.mainMenu();

          Scanner sc = new Scanner(System.in);
          String option = sc.nextLine();

          Menu.classifyOption(option,bookList,setupBook,in,movieList,setupMovieList,len,userList);
          }
            if(userList[len].getIdentity().equals("librarian")){
                setupUsers.printUserList(userList,len);
            }
        }
        if(len>=userList.length){
            System.out.println("login error.");
        }
    }

}
